'''
登录页面
'''
from time import sleep
import requests
from base.base_page import BasePage, BoxDriver


class LoginPage(BasePage):

    def login(self, user='v_chenguangde', pwd='125986cgd@1'):

        driver = self.driver

        # 加载数据文件
        config = self.get_yaml(r'C:\codes\UIAuto\data\user_data.yaml')

        # 口令返回值
        url = 'https://dashboard-mng.biliapi.net/api/v4/totp/get_current_user_token'
        header = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36',
            'Cookie': '_AJSESSIONID=2cc748afe5963ec1ad302f490c7f34e2; username=v_chenguangde; SecuritySSOSessionID=f1a9787d32463e08b51eac01f1fc9e57'
        }
        r = requests.get(url, headers=header)
        result = r.json()
        ss = result['data']['token']


        # 定位信息
        START = config['LoginPage']['START']
        ACCOUNT = config['LoginPage']['USER']
        PASSWORD = config['LoginPage']['PWD']
        COMMAND = config['LoginPage']['COMMAND']
        SUBMIT = config['LoginPage']['SUBMIT']

        # 登陆
        driver.click(START)
        driver.input(ACCOUNT, user)
        driver.input(PASSWORD, pwd)
        driver.input(COMMAND, ss)
        driver.click(SUBMIT)
        sleep(10)




if __name__ == '__main__':
    imgs = []
    LoginPage(BoxDriver(imgs)).login()










